package org.dtrevien.ihm;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Insets;

import javax.swing.JTextArea;

public class JTextAreaLined extends JTextArea {

	public JTextAreaLined() {
		super();
		setMargin(new Insets(0, 40, 0, 0));
	}
	
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		float offsety = 8, offsety2 = 19, lineheight = 15f;
		boolean line = true;
		
		g.setColor(Color.gray);
		g.drawLine(30, 0, 30, this.getHeight());
		
		for (int i = 0; i < super.getHeight()/lineheight; i++) {
			if (line) {
				g.setColor(new Color(0, 0, 1, 0.03f));
				g.fillRect(0, (int)(offsety+(i*lineheight)), super.getWidth(), (int)lineheight);
				line = false;
			}
			else
				line = true;
			
			g.setColor(Color.black);
			g.drawString((i+1)+"", 2, (int) (offsety2+(i*lineheight)));
		}
		
		g.setColor(new Color(1,1,1,0.5f));
		g.fillRect(0, 0, 30, this.getHeight());
	}
}
